package com.bdqn.ch06.repository;

import com.bdqn.ch06.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Long>,JpaSpecificationExecutor<User> {

    public List<User> findByUsrName(String usrName);

    public User findUserByUsrName(String usrName);

    public List<User> findByUsrNameOrUsrPassword(String usrName, String usrPassword);

    // @Query("select u from User u where u.usrRoleId=?1")
    // public List<User> findByRoleId(Long roleId);

    @Query("select u from User u")
    public Page<User> findUserPage(Pageable pageable);

}